<!--代码逻辑和样式库-->
<script src="./department-manage.component.js"></script>
<style src="./department-manage.scss" scoped lang="scss"></style>

<template>
  <div>
    <!-- 操作按钮 -->
    <!-- 内容区域 -->
    <div class="content-container aq-margin-top-16">
      <!--部门树状表格 -->
      <el-table
        :data="data"
        row-key="text"
        border
        default-expand-all
        :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
        <el-table-column prop="text" label="部门名称">
          <template slot-scope="scope">
            {{ scope.row.text }}
            <el-link class="aq-margin-left-16" v-if="codesCheck.indexOf('Create') !== -1" icon="el-icon-circle-plus-outline" type="success" @click="openEditDialog('create', scope.row)">创建</el-link>
            <el-link class="aq-margin-left-16" v-if="codesCheck.indexOf('Edit') != -1" icon="el-icon-edit" type="primary" @click="openEditDialog('edit', scope.row)">编辑</el-link>
            <el-link class="aq-margin-left-16" v-if="codesCheck.indexOf('Delete') != -1" icon="el-icon-delete" size="mini" type="danger" @click="deleteSelectedData(scope.row.id)">删除</el-link>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!--创建、编辑部门弹窗-->
    <el-dialog :title="dialogTitle" :visible.sync="editDialogVisible" width="500px">
      <el-form ref="dataForm" :rules="editRules" :model="editForm" label-position="right" label-width="85px">
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item prop="text" label="组织名称:">
              <el-input v-model="editForm.text" class="el-input-width"/>
            </el-form-item>
            <el-form-item prop="code" label="上级组织:" class="aq-margin-bottom-0">
              {{ editForm.parentName }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :sm="24" :lg="24" align="right" class="aq-margin-top-12">
            <el-button class="action-btn" @click="editDialogVisible = false">取消</el-button>
            <el-button class="action-btn" type="primary" @click="save()">确定</el-button>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>
  </div>
</template>
